package com.snmp.smn.manager;

import java.util.List;
import java.util.TimerTask;

import com.snmp.smn.beans.Device;
import com.snmp.smn.db.DBHelper;
import com.snmp.smn.monitors.HTTPMonitor;
import com.snmp.smn.monitors.MySQLDBMonitor;

public class DevicesMonitorTask extends TimerTask {

	@Override
	public void run() {
		try {
			List<Device> devices = DBHelper.getDevices();
			
			for (Device device : devices) {
				if (device.getDeviceType().equalsIgnoreCase("HTTP")) {
					new HTTPMonitor(device).checkDevice();
				} else if (device.getDeviceType().equalsIgnoreCase("MYSQLDB")) {
					new MySQLDBMonitor(device).checkDevice();
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
